package com.love.marriage.cloud.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.love.marriage.cloud.service.CallService;
import com.love.marriage.cloud.service.VirtualNumberService;
import com.love.marriage.common.vo.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * description:  用户登录历史表restApi
 * author:       mybatisPlus
 * createDate:   2024-10-12 11:25:06
 * version:      1.0.0
 */
@ApiSort(100)
@Tag(name = "阿里云通话", description = "阿里云通话相关接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/aliyunDypls")
public class AliyunDyplsController {

    private final CallService callService;

    private final VirtualNumberService virtualNumberService;

    @ApiOperationSupport(order = 10, author = "alex")
    @Operation(summary = "绑定手机号", description = "绑定手机号")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = Result.class
                    )))
    @GetMapping(value = "/bindPhone")
    @Parameters({
            @Parameter(name = "phoneA", description = "打电话号码", required = true),
            @Parameter(name = "phoneB", description = "接电话号码", required = true)
    })
    @Tag(name = "公共", description = "公共接口")
    public Result<String> bindPhone(@RequestParam(value = "phoneA") String phoneA,
                                    @RequestParam(value = "phoneB") String phoneB) throws Exception {
        return Result.success(callService.bindPhone(phoneA, phoneB));
    }

    @ApiOperationSupport(order = 20, author = "alex")
    @Operation(summary = "绑定手机号", description = "绑定手机号")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = Result.class
                    )))
    @GetMapping(value = "/bindPhoneUserId")
    @Parameters({
            @Parameter(name = "userIdA", description = "电话号", required = true),
            @Parameter(name = "userIdB", description = "发送的消息", required = true)
    })
    @Tag(name = "公共", description = "公共接口")
    public Result<String> bindPhoneUserId(@RequestParam(value = "userIdA") Long userIdA,
                                          @RequestParam(value = "userIdB") Long userIdB) throws Exception {
        return Result.success(callService.bindPhoneUserId(userIdA, userIdB));
    }

    @ApiOperationSupport(order = 30, author = "alex")
    @Operation(summary = "添加虚拟号码池", description = "添加虚拟号码池")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = Result.class
                    )))
    @GetMapping(value = "/addVirtualNumberPool")
    @Parameters({
            @Parameter(name = "virtualNumbers", description = "虚拟号码", required = true)
    })
    @Tag(name = "公共", description = "公共接口")
    public Result<Boolean> addVirtualNumberPool(@RequestParam(value = "virtualNumbers") String... virtualNumbers) throws Exception {
        return Result.success(virtualNumberService.initVirtualNumberPool(virtualNumbers));
    }
}
